import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';

class Home extends React.Component {
  static propTypes = {
    user: PropTypes.object,
  }

  static defaultProps = {
    user: {},
  }

  componentWillMount = () => {
    console.log('componentWillMount~~~');
  }

  componentDidMount = () => {
    console.log('componentDidMount~~~');
  }

  render() {
    const { user } = this.props;
    return (
      <div className="page page__home">
        <p>首页~~~</p>
        <div className="user__info">
          <ul>
            <li>{user.login}</li>
            <li>{user.created_at}</li>
          </ul>
        </div>
      </div>
    );
  }
}

const mapStateToProps = (state) => {
  const { user } = state;
  return {
    user,
  };
};

export default connect(mapStateToProps)(Home);
